// 03myCenter/02sectorization/08nameAuthentication/nameAuthentication.js
var co = require('../../../resource/js/common.js')
var app = getApp()
var _this

Page({

   /* 页面的初始数据*/
   data: {
      // 用户信息
      userInfo: '',
      // 是否已经提交
      isSubmit: true,
      isShow: false
   },

   /*生命周期函数--监听页面加载*/
   onLoad: function (options) {
      _this = this
      var ID_Card_Name = app.Data.userInfo.ID_Card_Name
      //判断是否已经实名认证
      if ( ID_Card_Name != ''){
         this.setData({ 
            isSubmit: false,
            isShow: true,
            userInfo: app.Data.userInfo
         })
      }
   },
   //身份证信息提交
   formSumbit: function (e) {
      var UN = e.detail.value.userName
      var IDN = e.detail.value.idNumber
      var param = {
         User_ID: app.Data.userInfo.User_ID,
         name: UN,
         idCard: IDN
      }
      co.getShareApi('api/Idcard/check', param, function(res){
         // 存入app用户信息中
         if(res.data == 0){
             app.Data.userInfo = res.data
             _this.onLoad()
         }

      })
   }
})